<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.linenumber {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='linenumber'>  1</span> <span class="COMM">/*
<span class='linenumber'>  2</span>  * ====================================================================
<span class='linenumber'>  3</span>  * About Sarissa: http://dev.abiss.gr/sarissa
<span class='linenumber'>  4</span>  * ====================================================================
<span class='linenumber'>  5</span>  * Sarissa table utils are dependent on sarissa.js and are used for 
<span class='linenumber'>  6</span>  * stuff like table sorting.
<span class='linenumber'>  7</span>  * @version 0.9.9.4
<span class='linenumber'>  8</span>  * @author: Copyright 2004-2008 Emmanouil Batsis, mailto: mbatsis at users full stop sourceforge full stop net
<span class='linenumber'>  9</span>  * ====================================================================
<span class='linenumber'> 10</span>  * Licence
<span class='linenumber'> 11</span>  * ====================================================================
<span class='linenumber'> 12</span>  * Sarissa is free software distributed under the GNU GPL version 2 (see &lt;a href="gpl.txt">gpl.txt&lt;/a>) or higher, 
<span class='linenumber'> 13</span>  * GNU LGPL version 2.1 (see &lt;a href="lgpl.txt">lgpl.txt&lt;/a>) or higher and Apache Software License 2.0 or higher 
<span class='linenumber'> 14</span>  * (see &lt;a href="asl.txt">asl.txt&lt;/a>). This means you can choose one of the three and use that if you like. If 
<span class='linenumber'> 15</span>  * you make modifications under the ASL, i would appreciate it if you submitted those.
<span class='linenumber'> 16</span>  * In case your copy of Sarissa does not include the license texts, you may find
<span class='linenumber'> 17</span>  * them online in various formats at &lt;a href="http://www.gnu.org">http://www.gnu.org&lt;/a> and 
<span class='linenumber'> 18</span>  * &lt;a href="http://www.apache.org">http://www.apache.org&lt;/a>.
<span class='linenumber'> 19</span>  *
<span class='linenumber'> 20</span>  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 
<span class='linenumber'> 21</span>  * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 
<span class='linenumber'> 22</span>  * WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE 
<span class='linenumber'> 23</span>  * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 
<span class='linenumber'> 24</span>  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
<span class='linenumber'> 25</span>  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
<span class='linenumber'> 26</span>  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 
<span class='linenumber'> 27</span>  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
<span class='linenumber'> 28</span>  */</span><span class="WHIT">
<span class='linenumber'> 29</span> 
<span class='linenumber'> 30</span> </span><span class="COMM">/**
<span class='linenumber'> 31</span>  * Sort the table data based on the column corresponding to the given TH element (clickedElem).
<span class='linenumber'> 32</span>  * @memberOf Sarissa
<span class='linenumber'> 33</span>  * @param {Node} clickedElem the table heading (&lt;code>th&lt;/code>) initiating the sort.
<span class='linenumber'> 34</span>  * @param {Function} iFunc the custom sort function if needed. Default (null) is case-sensitive sort.
<span class='linenumber'> 35</span>  * You can also use &lt;code>Sarissa.SORT_IGNORE_CASE&lt;/code>, &lt;code>Sarissa.SORT_DATE_US&lt;/code>, 
<span class='linenumber'> 36</span>  * and &lt;code>Sarissa.SORT_DATE_EU&lt;/code>
<span class='linenumber'> 37</span>  * @param {boolean} bSkipCache whether to skip the data cache and read table data all over again. Setting this
<span class='linenumber'> 38</span>  * to &lt;code>true&lt;/code> means the cache for the table, if it exists, will not be updated either. Defaul is &lt;code>false&lt;/code>
<span class='linenumber'> 39</span>  * @param {Function} oCallbac a callback function to be executed when the table is 
<span class='linenumber'> 40</span>  * sorted and updated. The callback function may be used for effects for example. The parameters 
<span class='linenumber'> 41</span>  * passed to the callback are the table as a DOM node and the sort column index (zero based &lt;code>int&lt;/code>)
<span class='linenumber'> 42</span>  * @requires Sarissa sarissa.js
<span class='linenumber'> 43</span>  */</span><span class="WHIT">
<span class='linenumber'> 44</span> </span><span class="NAME">Sarissa.sortHtmlTableData</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">clickedElem</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">iFunc</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">bSkipCache</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">oCallbac</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'> 45</span> 	</span><span class="COMM">// get the table</span><span class="WHIT">
<span class='linenumber'> 46</span> 	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">oTbl</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">clickedElem.parentNode.parentNode</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 47</span> 	</span><span class="KEYW">while</span><span class="PUNC">(</span><span class="NAME">oTbl.nodeName.toLowerCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">"table"</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'> 48</span> 	    </span><span class="NAME">oTbl</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">oTbl.parentNode</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 49</span> 	</span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'> 50</span> 	</span><span class="COMM">// we need a table ID for the cache</span><span class="WHIT">
<span class='linenumber'> 51</span> 	</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">oTbl.id</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'> 52</span> 		</span><span class="NAME">oTbl.id</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"SarissaTable"</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">Sarissa.tableIdGenCount</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 53</span> 	</span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'> 54</span> 	</span><span class="COMM">// the column to sort on</span><span class="WHIT">
<span class='linenumber'> 55</span> 	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">iColIndex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">clickedElem.cellIndex</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 56</span> 	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">matrix</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 57</span> 	</span><span class="COMM">// use the cache if available and permitted</span><span class="WHIT">
<span class='linenumber'> 58</span> 	</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">bSkipCache</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">Sarissa.tableDataCache</span><span class="PUNC">[</span><span class="NAME">oTbl.id</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'> 59</span> 		</span><span class="NAME">matrix</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Sarissa.tableDataCache</span><span class="PUNC">[</span><span class="NAME">oTbl.id</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 60</span> 	</span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'> 61</span> 	</span><span class="KEYW">else</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'> 62</span> 		</span><span class="COMM">// read table, skip any rows containing headings, cache if permitted</span><span class="WHIT">
<span class='linenumber'> 63</span> 		</span><span class="NAME">matrix</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.getArrayFromTableData</span><span class="PUNC">(</span><span class="NAME">oTbl</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"th"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 64</span> 		</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">bSkipCache</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'> 65</span> 			</span><span class="NAME">Sarissa.tableDataCache</span><span class="PUNC">[</span><span class="NAME">oTbl.id</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">matrix</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 66</span> 		</span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'> 67</span> 	</span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'> 68</span> 	</span><span class="COMM">// init state persistence as needed</span><span class="WHIT">
<span class='linenumber'> 69</span> 	</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">Sarissa.tableColumnSortStates</span><span class="PUNC">[</span><span class="NAME">oTbl.id</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'> 70</span> 		</span><span class="NAME">Sarissa.tableColumnSortStates</span><span class="PUNC">[</span><span class="NAME">oTbl.id</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 71</span> 	</span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'> 72</span> 	</span><span class="COMM">// build a array to sort from the specific column data, adding </span><span class="WHIT">
<span class='linenumber'> 73</span> 	</span><span class="COMM">// original index info as a suffix</span><span class="WHIT">
<span class='linenumber'> 74</span> 	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">sortedColumn</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 75</span> 	</span><span class="KEYW">for</span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">matrix.length</span><span class="PUNC">;</span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'> 76</span> 		</span><span class="NAME">sortedColumn</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Sarissa.stripTags</span><span class="PUNC">(</span><span class="NAME">matrix</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">iColIndex</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"_mbns_"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 77</span> 	</span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'> 78</span> 	</span><span class="COMM">// sort the array</span><span class="WHIT">
<span class='linenumber'> 79</span> 	</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">iFunc</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'> 80</span> 		</span><span class="NAME">sortedColumn.sort</span><span class="PUNC">(</span><span class="NAME">iFunc</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 81</span> 	</span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'> 82</span> 	</span><span class="KEYW">else</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'> 83</span> 		</span><span class="NAME">sortedColumn.sort</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 84</span> 	</span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'> 85</span> 	</span><span class="COMM">// persist column state</span><span class="WHIT">
<span class='linenumber'> 86</span> 	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">sortOrder</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Sarissa.tableColumnSortStates</span><span class="PUNC">[</span><span class="NAME">oTbl.id</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">iColIndex</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 87</span> 	</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">sortOrder</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">"asc"</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'> 88</span> 		</span><span class="NAME">Sarissa.tableColumnSortStates</span><span class="PUNC">[</span><span class="NAME">oTbl.id</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">iColIndex</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"asc"</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 89</span> 	</span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'> 90</span> 	</span><span class="KEYW">else</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'> 91</span> 		</span><span class="NAME">sortedColumn.reverse</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 92</span> 		</span><span class="NAME">Sarissa.tableColumnSortStates</span><span class="PUNC">[</span><span class="NAME">oTbl.id</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">iColIndex</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"desc"</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 93</span> 	</span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'> 94</span> 	</span><span class="COMM">// create the sorted matrix based on sortedColumn</span><span class="WHIT">
<span class='linenumber'> 95</span> 	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">sortedMatrix</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 96</span> 	</span><span class="KEYW">for</span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">j</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">j</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">matrix.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">j</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'> 97</span> 		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">indexItem</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sortedColumn</span><span class="PUNC">[</span><span class="NAME">j</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 98</span> 		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">iRow</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">indexItem.substring</span><span class="PUNC">(</span><span class="NAME">indexItem.indexOf</span><span class="PUNC">(</span><span class="STRN">"_mbns_"</span><span class="PUNC">)</span><span class="PUNC">+</span><span class="NUMB">6</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">indexItem.length</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 99</span> 		</span><span class="NAME">sortedMatrix</span><span class="PUNC">[</span><span class="NAME">j</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>100</span> 		</span><span class="KEYW">for</span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">k</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">matrix</span><span class="PUNC">[</span><span class="NAME">j</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>101</span> 			</span><span class="NAME">sortedMatrix</span><span class="PUNC">[</span><span class="NAME">j</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">k</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">matrix</span><span class="PUNC">[</span><span class="NAME">iRow</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">k</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>102</span> 		</span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>103</span> 	</span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>104</span> 	</span><span class="COMM">// update table data, skipping rows with headings</span><span class="WHIT">
<span class='linenumber'>105</span> 	</span><span class="NAME">this.updateTableData</span><span class="PUNC">(</span><span class="NAME">oTbl</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sortedMatrix</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"th"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>106</span> 	</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">oCallbac</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>107</span> 		</span><span class="NAME">oCallbac</span><span class="PUNC">(</span><span class="NAME">oTbl</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">iColIndex</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">	
<span class='linenumber'>108</span> 	</span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>109</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>110</span> 
<span class='linenumber'>111</span> </span><span class="COMM">/**
<span class='linenumber'>112</span>  * Used for generating table IDs, which are required for the cache and sort state persistance 
<span class='linenumber'>113</span>  * @memberOf Sarissa
<span class='linenumber'>114</span>  * @private
<span class='linenumber'>115</span>  */</span><span class="WHIT">
<span class='linenumber'>116</span> </span><span class="NAME">Sarissa.tableIdGenCount</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>117</span> 
<span class='linenumber'>118</span> </span><span class="COMM">/**
<span class='linenumber'>119</span>  * Used for persisting sort state per table column
<span class='linenumber'>120</span>  * @memberOf Sarissa
<span class='linenumber'>121</span>  * @private
<span class='linenumber'>122</span>  */</span><span class="WHIT">
<span class='linenumber'>123</span> </span><span class="NAME">Sarissa.tableColumnSortStates</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>124</span> 
<span class='linenumber'>125</span> </span><span class="COMM">/**
<span class='linenumber'>126</span>  * Used for caching table data.
<span class='linenumber'>127</span>  * @memberOf Sarissa
<span class='linenumber'>128</span>  */</span><span class="WHIT">
<span class='linenumber'>129</span> </span><span class="NAME">Sarissa.tableDataCache</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>130</span> 
<span class='linenumber'>131</span> </span><span class="COMM">/**
<span class='linenumber'>132</span>  * Keep track of the cache size. The length property is not for associative arrays 
<span class='linenumber'>133</span>  * and I really dont want to add 50 lines and implement a PseudoHashMap right now :-)
<span class='linenumber'>134</span>  * @memberOf Sarissa
<span class='linenumber'>135</span>  * @private
<span class='linenumber'>136</span>  */</span><span class="WHIT">
<span class='linenumber'>137</span> </span><span class="NAME">Sarissa.tableDataCacheSize</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>138</span> 
<span class='linenumber'>139</span> </span><span class="COMM">/**
<span class='linenumber'>140</span>  * The table data cache size, used for sorting HTML tables. You can change it, default is 5 (tables). When a  
<span class='linenumber'>141</span>  * table is cached exceeding the cache size, the oldest entry is disgarded from the cache.
<span class='linenumber'>142</span>  * @memberOf Sarissa
<span class='linenumber'>143</span>  */</span><span class="WHIT">
<span class='linenumber'>144</span> </span><span class="NAME">Sarissa.tableDataCacheMaxSize</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">5</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>145</span> 
<span class='linenumber'>146</span> </span><span class="COMM">/**
<span class='linenumber'>147</span>  * Updates the cache, discards oldest entry if cache size is exceeded.
<span class='linenumber'>148</span>  * @memberOf Sarissa
<span class='linenumber'>149</span>  * @private
<span class='linenumber'>150</span>  */</span><span class="WHIT">
<span class='linenumber'>151</span> </span><span class="NAME">Sarissa.tableDataCachePut</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">sTableId</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">oArr</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>152</span> 	</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">Sarissa.tableDataCacheSize.length</span><span class="WHIT"> </span><span class="PUNC">>=</span><span class="WHIT"> </span><span class="NAME">Sarissa.tableDataCacheMaxSize</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>153</span> 		</span><span class="NAME">Sarissa.tableDataCache.shift</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>154</span> 		</span><span class="NAME">Sarissa.tableDataCacheSize</span><span class="PUNC">--</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>155</span> 	</span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>156</span> 	</span><span class="NAME">Sarissa.tableDataCache</span><span class="PUNC">[</span><span class="NAME">sTableId</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">oArr</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>157</span> 	</span><span class="NAME">Sarissa.tableDataCacheSize</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>158</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>159</span> </span><span class="COMM">/**
<span class='linenumber'>160</span>  * Updates the cache of a specific table by reposition a column in the cached data.
<span class='linenumber'>161</span>  * This is usefull if you use DHTML to visually reposition columns and need to 
<span class='linenumber'>162</span>  * synchronize the cache.
<span class='linenumber'>163</span>  * @memberOf Sarissa
<span class='linenumber'>164</span>  * @private
<span class='linenumber'>165</span>  */</span><span class="WHIT">
<span class='linenumber'>166</span> </span><span class="NAME">Sarissa.tableDataCacheMoveColumn</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">sTableId</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">oldColumnIndex</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">newColumnIndex</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">	
<span class='linenumber'>167</span> 	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">oldMatrix</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Sarissa.tableDataCache</span><span class="PUNC">[</span><span class="NAME">sTableId</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>168</span> 	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">newMatrix</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>169</span> 	</span><span class="COMM">// iterate rows</span><span class="WHIT">
<span class='linenumber'>170</span> 	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">oldRow</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">movedColumn</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">newRow</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>171</span> 	</span><span class="KEYW">for</span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">&lt;</span><span class="NAME">oldMatrix.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>172</span> 		</span><span class="NAME">oldRow</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">oldMatrix</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>173</span> 		</span><span class="NAME">movedColumn</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">oldRow.splice</span><span class="PUNC">(</span><span class="NAME">oldColumnIndex</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>174</span> 		</span><span class="NAME">newRow</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>175</span> 		</span><span class="COMM">// reposition column value</span><span class="WHIT">
<span class='linenumber'>176</span> 		</span><span class="KEYW">for</span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">j</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="NAME">j</span><span class="PUNC">&lt;</span><span class="NAME">oldArr.length</span><span class="PUNC">;</span><span class="NAME">J</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>177</span> 			</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">j</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">newColumnIndex</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>178</span> 				</span><span class="NAME">newRow.put</span><span class="PUNC">(</span><span class="NAME">movedColumn</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>179</span> 			</span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>180</span> 			</span><span class="NAME">newRow.put</span><span class="PUNC">(</span><span class="NAME">oldRow</span><span class="PUNC">[</span><span class="NAME">j</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>181</span> 		</span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>182</span> 		</span><span class="NAME">newMatrix</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">newRow</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>183</span> 	</span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>184</span> 	</span><span class="NAME">Sarissa.tableDataCache</span><span class="PUNC">[</span><span class="NAME">sTableId</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">newMatrix</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>185</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>186</span> 
<span class='linenumber'>187</span> </span><span class="COMM">/**
<span class='linenumber'>188</span>  * Function for case-insensitive sorting or simple comparison. Can be used as 
<span class='linenumber'>189</span>  * a parameter to &lt;code>Array.sort()&lt;/code>.
<span class='linenumber'>190</span>  * @memberOf Sarissa
<span class='linenumber'>191</span>  * @param a a string
<span class='linenumber'>192</span>  * @param b a string
<span class='linenumber'>193</span>  * @return -1, 0 or 1 depending on whether &lt;code>a&lt;/code> is "less than", equal or "greater than" &lt;code>b&lt;/code>
<span class='linenumber'>194</span>  */</span><span class="WHIT">
<span class='linenumber'>195</span> </span><span class="NAME">Sarissa.SORT_IGNORE_CASE</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">b</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>196</span>   </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">strA</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">a.toLowerCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='linenumber'>197</span>       </span><span class="NAME">strB</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">b.toLowerCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>198</span>   </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">strA</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">strB</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>199</span>   </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">strA</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NAME">strB</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>200</span>   </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>201</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>202</span> 
<span class='linenumber'>203</span> </span><span class="COMM">/**
<span class='linenumber'>204</span>  * Function for comparing US dates. Can be used as 
<span class='linenumber'>205</span>  * a parameter to &lt;code>Array.sort()&lt;/code>.
<span class='linenumber'>206</span>  * @memberOf Sarissa
<span class='linenumber'>207</span>  * @param a a string
<span class='linenumber'>208</span>  * @param b a string
<span class='linenumber'>209</span>  * @return -1, 0 or 1 depending on whether &lt;code>a&lt;/code> is "less than", equal or "greater than" &lt;code>b&lt;/code>
<span class='linenumber'>210</span>  */</span><span class="WHIT">
<span class='linenumber'>211</span> </span><span class="NAME">Sarissa.SORT_DATE_US</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">b</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>212</span> 	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">datA</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Date</span><span class="PUNC">(</span><span class="NAME">a.substring</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">a.lastIndexOf</span><span class="PUNC">(</span><span class="STRN">"_mbns_"</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='linenumber'>213</span> 		</span><span class="NAME">datB</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Date</span><span class="PUNC">(</span><span class="NAME">b.substring</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">b.lastIndexOf</span><span class="PUNC">(</span><span class="STRN">"_mbns_"</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>214</span> 	</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">datA</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">datB</span><span class="PUNC">)</span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>215</span> 	</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">datA</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NAME">datB</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>216</span>     </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>217</span>     
<span class='linenumber'>218</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>219</span> 
<span class='linenumber'>220</span> </span><span class="COMM">/**
<span class='linenumber'>221</span>  * Function for comparing EU dates. Can be used as 
<span class='linenumber'>222</span>  * a parameter to &lt;code>Array.sort()&lt;/code>.
<span class='linenumber'>223</span>  * @memberOf Sarissa
<span class='linenumber'>224</span>  * @param a a string
<span class='linenumber'>225</span>  * @param b a string
<span class='linenumber'>226</span>  * @return -1, 0 or 1 depending on whether &lt;code>a&lt;/code> is "less than", equal or "greater than" &lt;code>b&lt;/code>
<span class='linenumber'>227</span>  */</span><span class="WHIT">
<span class='linenumber'>228</span> </span><span class="NAME">Sarissa.SORT_DATE_EU</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">b</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>229</span> 	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">strA</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">a.substring</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">a.lastIndexOf</span><span class="PUNC">(</span><span class="STRN">"_mbns_"</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">split</span><span class="PUNC">(</span><span class="STRN">"/"</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='linenumber'>230</span> 		</span><span class="NAME">strB</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">b.substring</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">b.lastIndexOf</span><span class="PUNC">(</span><span class="STRN">"_mbns_"</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">split</span><span class="PUNC">(</span><span class="STRN">"/"</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='linenumber'>231</span> 		</span><span class="NAME">datA</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Date</span><span class="PUNC">(</span><span class="NAME">strA</span><span class="PUNC">[</span><span class="NUMB">2</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">strA</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">strA</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='linenumber'>232</span> 		</span><span class="NAME">datB</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Date</span><span class="PUNC">(</span><span class="NAME">strB</span><span class="PUNC">[</span><span class="NUMB">2</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">strB</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">strB</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>233</span> 	</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">datA</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">datB</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>234</span> 	</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">datA</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NAME">datB</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>235</span>     </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>236</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>237</span> 
<span class='linenumber'>238</span> </span><span class="COMM">/**
<span class='linenumber'>239</span>  * Get the data of the given element as a two-dimensional array. The 
<span class='linenumber'>240</span>  * given XML or HTML Element must match the structure of an HTML table, 
<span class='linenumber'>241</span>  * although element names may be different.
<span class='linenumber'>242</span>  * @memberOf Sarissa
<span class='linenumber'>243</span>  * @param oElem an HTML or XML table. The method works out of the box 
<span class='linenumber'>244</span>  * for &lt;code>table&lt;/code>, &lt;code>tbody&lt;/code>, &lt;code>thead&lt;/code> 
<span class='linenumber'>245</span>  * or &lt;code>tfooter&lt;/code> elements. For custom XML tables, the 
<span class='linenumber'>246</span>  * &lt;code>sRowName&lt;/code> &lt;code>sCellName&lt;/code> must be used.
<span class='linenumber'>247</span>  * @param sRowName the row element names. Default is &lt;code>tr&lt;/code>
<span class='linenumber'>248</span>  * @param sCellName the row element names. Default is &lt;code>td&lt;/code>
<span class='linenumber'>249</span>  * @param sHeadingName the heading element names. If you use this, rows with 
<span class='linenumber'>250</span>  * headings will be &lt;strong>skipped&lt;/strong>. To skip headings when reading 
<span class='linenumber'>251</span>  * HTML tables use &lt;code>th&lt;/code>
<span class='linenumber'>252</span>  * @param bStripTags whether to strip markup from cell contents. Default is &lt;code>false&lt;/code>
<span class='linenumber'>253</span>  * @return a two-dimensional array with the data found in the given element's rows
<span class='linenumber'>254</span>  */</span><span class="WHIT">
<span class='linenumber'>255</span> </span><span class="NAME">Sarissa.getArrayFromTableData</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">oElem</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sRowName</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sCellName</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sHeadingName</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">bStripTags</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>256</span> 	</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">sRowName</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>257</span> 		</span><span class="NAME">sRowName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"tr"</span><span class="WHIT">
<span class='linenumber'>258</span> 	</span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>259</span> 	</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">sCellName</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>260</span> 		</span><span class="NAME">sCellName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"td"</span><span class="WHIT">
<span class='linenumber'>261</span> 	</span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>262</span> 	</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">sHeadingName</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>263</span> 		</span><span class="NAME">sHeadingName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"th"</span><span class="WHIT">
<span class='linenumber'>264</span> 	</span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>265</span> 	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">rows</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">oElem.getElementsByTagName</span><span class="PUNC">(</span><span class="NAME">sRowName</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>266</span> 	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">matrix</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>267</span> 	</span><span class="KEYW">for</span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">j</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">rows.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>268</span> 		</span><span class="COMM">// skip rows with headings</span><span class="WHIT">
<span class='linenumber'>269</span> 		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">row</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">rows</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>270</span> 		</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">sHeadingName</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">row.getElementsByTagName</span><span class="PUNC">(</span><span class="NAME">sHeadingName</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">length</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>271</span> 			</span><span class="NAME">matrix</span><span class="PUNC">[</span><span class="NAME">j</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>272</span> 			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">cells</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">row.getElementsByTagName</span><span class="PUNC">(</span><span class="NAME">sCellName</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>273</span> 			</span><span class="KEYW">for</span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">k</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">cells.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>274</span> 				</span><span class="NAME">matrix</span><span class="PUNC">[</span><span class="NAME">j</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">k</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">bStripTags</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">Sarissa.stripTags</span><span class="PUNC">(</span><span class="NAME">cells</span><span class="PUNC">[</span><span class="NAME">k</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">innerHTML</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">cells</span><span class="PUNC">[</span><span class="NAME">k</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">innerHTML</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>275</span> 			</span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>276</span> 			</span><span class="NAME">j</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>277</span> 		</span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>278</span> 	</span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>279</span> 	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">matrix</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>280</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>281</span> 
<span class='linenumber'>282</span> </span><span class="COMM">/**
<span class='linenumber'>283</span>  * Update the data of the given element using the giventwo-dimensional array as a source. The 
<span class='linenumber'>284</span>  * given XML or HTML Element must match the structure of an HTML table.
<span class='linenumber'>285</span>  * @memberOf Sarissa
<span class='linenumber'>286</span>  * @param oElem an HTML or XML table. The method works out of the box 
<span class='linenumber'>287</span>  * for &lt;code>table&lt;/code>, &lt;code>tbody&lt;/code>, &lt;code>thead&lt;/code> 
<span class='linenumber'>288</span>  * or &lt;code>tfooter&lt;/code> elements. For custom XML tables, the 
<span class='linenumber'>289</span>  * &lt;code>sRowName&lt;/code> &lt;code>sCellName&lt;/code> must be used.
<span class='linenumber'>290</span>  * @param sRowName the row element names. Default is &lt;code>tr&lt;/code>
<span class='linenumber'>291</span>  * @param sCellName the row element names. Default is &lt;code>td&lt;/code>
<span class='linenumber'>292</span>  * @param sHeadingName the heading element names. If you use this, rows with 
<span class='linenumber'>293</span>  * headings will be &lt;strong>skipped&lt;/strong>. To skip headings when reading 
<span class='linenumber'>294</span>  * HTML tables use &lt;code>th&lt;/code>
<span class='linenumber'>295</span>  */</span><span class="WHIT">
<span class='linenumber'>296</span> </span><span class="NAME">Sarissa.updateTableData</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">oElem</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">newData</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sRowName</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sCellName</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sHeadingName</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>297</span> 	</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">sRowName</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>298</span> 		</span><span class="NAME">sRowName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"tr"</span><span class="WHIT">
<span class='linenumber'>299</span> 	</span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>300</span> 	</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">sCellName</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>301</span> 		</span><span class="NAME">sCellName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"td"</span><span class="WHIT">
<span class='linenumber'>302</span> 	</span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>303</span> 	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">rows</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">oElem.getElementsByTagName</span><span class="PUNC">(</span><span class="NAME">sRowName</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>304</span> 	</span><span class="KEYW">for</span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">j</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">newData.length</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">j</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">rows.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">j</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>305</span> 		</span><span class="COMM">// skip rows with headings</span><span class="WHIT">
<span class='linenumber'>306</span> 		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">row</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">rows</span><span class="PUNC">[</span><span class="NAME">j</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>307</span> 		</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">sHeadingName</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">row.getElementsByTagName</span><span class="PUNC">(</span><span class="NAME">sHeadingName</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">length</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>308</span> 			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">cells</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">row.getElementsByTagName</span><span class="PUNC">(</span><span class="NAME">sCellName</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>309</span> 			</span><span class="KEYW">for</span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">k</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">cells.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>310</span> 				</span><span class="NAME">cells</span><span class="PUNC">[</span><span class="NAME">k</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">innerHTML</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">newData</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">k</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>311</span> 			</span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>312</span> 			</span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>313</span> 		</span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>314</span> 	</span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>315</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>316</span> 
<span class='linenumber'>317</span> 
<span class='linenumber'>318</span> </span></pre></body></html>